package com.cfl.ticketmodule.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cfl.ticketmodule.service.CityService;

@RestController
public class CityController {

	@Autowired
	private CityService cityService;
	
	/**
	 * 通过名称获取城市
	 * @param name
	 * @return
	 */
	@RequestMapping("findCityByName")
	public Object findByName(String name) {
		try {
			return cityService.findByName(name);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 通过城市cid获取城市
	 * @param cid
	 * @return
	 */
	@RequestMapping("findCityByCid")
	public Object findCityByCid(String cid) {
		try {
			return cityService.findByCid(cid);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	/**
	 * 获取所有城市
	 * @return
	 */
	@RequestMapping("findCityByAll")
	public Object findCityByAll() {
		try {
			return cityService.findCityByAll();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
